Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
check upgrade on start
Browse files Browse the repository at this point in the history
  • Loading branch information
Cenmrev committed Dec 24, 2018
1 parent 50f8b5e commit 2d52fed
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 11 deletions.
31 changes: 23 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,32 @@ sudo: false
install: true
script: xcodebuild -project V2RayX.xcodeproj -target V2RayX -configuration Release

after_success:
- isbeta=$(git describe --abbrev=0 --tags | grep beta)

before_deploy:
- cd build/Release/
- zip -r V2RayX.app.zip V2RayX.app
- cd ../..

deploy:
provider: releases
api_key:
secure: HjwZ8C70qYeozvaEUvKqDX42T26pRYiQBrTvzbqy8Q+BDWJZ7vNZhSwgt+oYGBywgpk0bM/Ao3al6YDlTE86bMiRUEGSFjRWo2Oquo4N5ydp5cmzT6sVigrLiviufAMrCrCljh0OEt/hEN7wf7zJ8SZKFCLOi8AhTkJu8yEuFdx/2Zd/VSOs6AFp0s1uGrfd3UmwxWfGcKatpYb4GcCwZk2PrECc0qkAP9UzGjemU1cYzcICi+cXl/NoMeLRftHSZaGl+zg95bvddSlNvyqvPwH/00hnh6kpjdyKMDQ071eFE+9NIShglm5yS9TcR3+fE6WfWU9SjTOnT2IfggvXfogcJWd7k4/AwFoAkezNiV0IMKXl2163T17pfFxVQo56oy9HtMts3bw5TapL2YiJa1PKzluSc5ijNcGdDh/7GIejne9lyTeHNhnE/Acmlt8Mu9N+gSj04R4sqN/GfTGzmlPC4kXB08RLg5ycHksGyf4YOLYe9wOEBN4UaSqepFsWqrrufj16l4dqTdacLdt2dJtkPsqCCiUu+nfVVZP9uibIMqWjBi+Fp2Rz+RIvaqtoQrMy+b1y/YwcVz9cJ29OMwU5hY6MehN5pqknwMhsDk1vH5m93swpL6wfM6CT7NjambVfPGffX8zYp/1l/CbBelzjaxZ/CbV4GHXkYHJ923s=
file: build/Release/V2RayX.app.zip
skip_cleanup: true
on:
repo: Cenmrev/V2RayX
tags: true
- provider: releases
prerelease: true
api_key:
secure: HjwZ8C70qYeozvaEUvKqDX42T26pRYiQBrTvzbqy8Q+BDWJZ7vNZhSwgt+oYGBywgpk0bM/Ao3al6YDlTE86bMiRUEGSFjRWo2Oquo4N5ydp5cmzT6sVigrLiviufAMrCrCljh0OEt/hEN7wf7zJ8SZKFCLOi8AhTkJu8yEuFdx/2Zd/VSOs6AFp0s1uGrfd3UmwxWfGcKatpYb4GcCwZk2PrECc0qkAP9UzGjemU1cYzcICi+cXl/NoMeLRftHSZaGl+zg95bvddSlNvyqvPwH/00hnh6kpjdyKMDQ071eFE+9NIShglm5yS9TcR3+fE6WfWU9SjTOnT2IfggvXfogcJWd7k4/AwFoAkezNiV0IMKXl2163T17pfFxVQo56oy9HtMts3bw5TapL2YiJa1PKzluSc5ijNcGdDh/7GIejne9lyTeHNhnE/Acmlt8Mu9N+gSj04R4sqN/GfTGzmlPC4kXB08RLg5ycHksGyf4YOLYe9wOEBN4UaSqepFsWqrrufj16l4dqTdacLdt2dJtkPsqCCiUu+nfVVZP9uibIMqWjBi+Fp2Rz+RIvaqtoQrMy+b1y/YwcVz9cJ29OMwU5hY6MehN5pqknwMhsDk1vH5m93swpL6wfM6CT7NjambVfPGffX8zYp/1l/CbBelzjaxZ/CbV4GHXkYHJ923s=
file: build/Release/V2RayX.app.zip
skip_cleanup: true
on:
repo: Cenmrev/V2RayX
tags: true
condition: "\"$isbeta\" != \"\""

- provider: releases
api_key:
secure: HjwZ8C70qYeozvaEUvKqDX42T26pRYiQBrTvzbqy8Q+BDWJZ7vNZhSwgt+oYGBywgpk0bM/Ao3al6YDlTE86bMiRUEGSFjRWo2Oquo4N5ydp5cmzT6sVigrLiviufAMrCrCljh0OEt/hEN7wf7zJ8SZKFCLOi8AhTkJu8yEuFdx/2Zd/VSOs6AFp0s1uGrfd3UmwxWfGcKatpYb4GcCwZk2PrECc0qkAP9UzGjemU1cYzcICi+cXl/NoMeLRftHSZaGl+zg95bvddSlNvyqvPwH/00hnh6kpjdyKMDQ071eFE+9NIShglm5yS9TcR3+fE6WfWU9SjTOnT2IfggvXfogcJWd7k4/AwFoAkezNiV0IMKXl2163T17pfFxVQo56oy9HtMts3bw5TapL2YiJa1PKzluSc5ijNcGdDh/7GIejne9lyTeHNhnE/Acmlt8Mu9N+gSj04R4sqN/GfTGzmlPC4kXB08RLg5ycHksGyf4YOLYe9wOEBN4UaSqepFsWqrrufj16l4dqTdacLdt2dJtkPsqCCiUu+nfVVZP9uibIMqWjBi+Fp2Rz+RIvaqtoQrMy+b1y/YwcVz9cJ29OMwU5hY6MehN5pqknwMhsDk1vH5m93swpL6wfM6CT7NjambVfPGffX8zYp/1l/CbBelzjaxZ/CbV4GHXkYHJ923s=
file: build/Release/V2RayX.app.zip
skip_cleanup: true
on:
repo: Cenmrev/V2RayX
tags: true
condition: "\"$isbeta\" = \"\""
1 change: 1 addition & 0 deletions V2RayX/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ int runCommandLine(NSString* launchPath, NSArray* arguments);
- (NSString*)logDirPath;

@property (strong, nonatomic) NSStatusItem *statusBarItem;
@property (weak) IBOutlet NSMenuItem *upgradeMenuItem;
@property (strong, nonatomic) IBOutlet NSMenu *statusBarMenu;
@property (weak, nonatomic) IBOutlet NSMenuItem *v2rayStatusItem;
@property (weak, nonatomic) IBOutlet NSMenuItem *enableV2rayItem;
Expand Down
25 changes: 24 additions & 1 deletion V2RayX/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

// resume the service when mac wakes up
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(didChangeStatus:) name:NSWorkspaceDidWakeNotification object:NULL];

[self checkUpgrade:self];
}

- (BOOL)installHelper:(BOOL)force {
Expand Down Expand Up @@ -170,6 +170,29 @@ - (BOOL)isSysconfVersionOK {
return YES;
}

- (IBAction)openReleasePage:(id)sender {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/Cenmrev/V2RayX/releases/latest"]];
}

- (IBAction)checkUpgrade:(id)sender {
NSURL* url =[NSURL URLWithString:@"https://api.github.com/repos/cenmrev/v2rayx/releases/latest"];
NSURLSessionDataTask* task = [[NSURLSession sharedSession] dataTaskWithURL:url completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSDictionary* d = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
@try {
if (![[d[@"tag_name"] substringFromIndex:1] isEqualToString:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]] && [d[@"prerelease"] isEqualToNumber:@NO]) {
self.upgradeMenuItem.hidden = false;
} else {
self.upgradeMenuItem.hidden = true;
}
} @catch (NSException *exception) {
self.upgradeMenuItem.hidden = true;
} @finally {
;
}
}];
[task resume];
}

- (void)readDefaults {
// just read defaults, didChangeStatus will handle invalid parameters.

Expand Down
7 changes: 7 additions & 0 deletions V2RayX/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<outlet property="serverListMenu" destination="eqU-gH-G4L" id="unc-2a-DIW"/>
<outlet property="serversItem" destination="3wi-Co-2Kd" id="kKi-8l-dDJ"/>
<outlet property="statusBarMenu" destination="yZm-2L-r3v" id="3iW-vb-TOn"/>
<outlet property="upgradeMenuItem" destination="29h-Cl-9kt" id="Fk0-Xq-OK0"/>
<outlet property="v2rayRulesItem" destination="bUi-AV-IfA" id="p4V-ny-gh7"/>
<outlet property="v2rayStatusItem" destination="EFa-yl-fQC" id="z3V-zp-jw7"/>
</connections>
Expand Down Expand Up @@ -757,6 +758,12 @@
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="YAD-DW-T91"/>
<menuItem title="Upgrade" id="29h-Cl-9kt">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="openReleasePage:" target="Voe-Tx-rLC" id="gMF-8x-ynd"/>
</connections>
</menuItem>
<menuItem title="Help" id="Yq1-i5-ecF">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
Expand Down
4 changes: 2 additions & 2 deletions V2RayX/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.0</string>
<string>1.5.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1129</string>
<string>1142</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>LSUIElement</key>
Expand Down

0 comments on commit 2d52fed

Please sign in to comment.